package top.huhuiyu.springboot3.p2301.service.api;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import top.huhuiyu.springboot3.p2301.config.ApiConfigInfo;

public interface ApiBaseService {

    default HttpHeaders getHeaders(ApiConfigInfo apiConfigInfo) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("app_id", apiConfigInfo.getApp_id());
        headers.add("app_secret", apiConfigInfo.getApp_secret());
        return headers;
    }

    default HttpEntity<String> baseHttpEntity(ApiConfigInfo apiConfigInfo) {
        return new HttpEntity<>("", getHeaders(apiConfigInfo));
    }

    default void sleep(long millis) {
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    default void sleep() {
        sleep(1000);
    }

}
